// 类型别名
// var str: string|number = "10"

// 类型别名可以用来给一个类型起新名字
// 采用关键字type 例如type Name = string | number
type strType = string|number|boolean;
var str:strType = "10"
str = 10
str = true

interface muchType1 {
  name: string
}
interface muchType2 {
  age: number
}
type muchType = muchType1 | muchType2
var obj: muchType = { name: "张三" }
var obj2: muchType = { age: 20 }
var obj3: muchType = { name: "李四", age: 15 }

// 也可也采用type来约束取值只能是某些字符串中的一个
// 限制字符串的选择
type sex = "男" | "女"
function getSex(s:sex): string{
  return s
}
getSex("女")

export {}
